package org.eclipse.team.search.tests;

import junit.framework.Test;
import junit.framework.TestSuite;

import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.team.internal.search.ResourceCounter;
import org.eclipse.team.tests.ccvs.core.CVSTestSetup;
import org.eclipse.team.tests.ccvs.core.EclipseTest;

public class CVSSearchTest extends EclipseTest {
	
	public static Test suite() {
		TestSuite suite = new TestSuite();
		suite.addTestSuite(CVSSearchTest.class);
		return new CVSTestSetup(suite);
	}

	private IProject project;

	@Override
	protected void setUp() throws Exception {
		super.setUp();
		// + CVSSearchTest
		//   + folder1
		//      + folder3
		//         + file3.txt
		//      + file2.txt
		//   + folder2
		//     + file4.txt
		project = createProject("CVSSearchTest", new String[] { "file1.txt",
				"folder1/", "folder2/", "folder1/file2.txt", "folder1/folder3/",
				"folder1/folder3/file3.txt", "folder2/file4.txt"});
		setContentsAndEnsureModified(project.getFolder("folder2").getFile(
				"file4.txt"), "initial commit\n\n");
		commitResources(new IResource[] { project.getFolder("folder2").getFile(
				"file4.txt") }, IResource.DEPTH_INFINITE,
				"Bug 1 - very important fix");
	}
	
	
	public void testResourceCounter() throws CoreException{
		ResourceCounter rc = new ResourceCounter();
		project.accept(rc);
		assertEquals("ResourceCounter did not count resources correctly",
				5 /* just a guess, I want to have it running */, rc
						.getResourceCount());
	}

}
